package com.liqi.web.controller.openapi.middleware;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.liqi.common.core.domain.R;
import com.liqi.common.utils.mqtt.MqttConfig;
import com.liqi.common.utils.mqtt.MqttPushClient;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 中间件心跳上报接口
 * 
 * @author xxx
 */
@Api(tags = "提供给中间件的接口")
@RestController
@RequestMapping("/openApi/middleware")
public class MqttPublishController {
	@Autowired
	private MqttConfig mqttConfig;
	
	/**
	 * 心跳上报
	 */
	@ApiOperation("发布信息")
	@PostMapping(value = "/publishMessage")
	public R publishMessage() {
		String deviceId = "test";
		MqttPushClient client = mqttConfig.getDeviceIdMqttPushClient(deviceId);
		
		client.publish(0, false, deviceId, "kolo123");
		
		R r = R.ok();
		return r;
	}

}
